package com.galeno.utils;

import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/11/1121:32
 */
public class ConnectionUtils {
    public static Connection getHbaseConn(ParameterTool parameterTool)throws Exception{
        Configuration hbaseConf= HBaseConfiguration.create();
        hbaseConf.set("hbase.zookeeper.quorum",parameterTool.getRequired("hbase.zookeeper.quorum"));
        hbaseConf.setInt("hbase.zookeeper.property.clientPort",parameterTool.getInt("hbase.zookeeper.property.clientPort",2181));
        return ConnectionFactory.createConnection(hbaseConf);
    }
    public static java.sql.Connection getClickHouseConn(ParameterTool parameterTool) throws SQLException {
        return DriverManager.getConnection(parameterTool.getRequired("clickhouse.url"));
    }

}
